<?php

namespace app\master\controller;

use think\Db;
use think\Exception;

class Platform extends Base
{
    //平台概况
    public function news()
    {

        $message = db('message')->order('message_id desc')->find();
        $data['usercount'] = db('member')->where('member_status', 1)->count();
        $data['drivecount'] = db('drive')->where('drive_status', 'not in', 4)->count();
        $data['drivelogincount'] = db('drive')->where('drive_status', 1)->count();
        $data['carcount'] = db('car')->where('car_status', 1)->count();
        $data['carstaycount'] = db('car')->where(['car_types' => 1, 'car_status' => 1])->count();


        $today_start = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
        $today_end = mktime(23, 59, 59, date('m'));
        $where = [
            'create_time' => array('BETWEEN', array($today_start, $today_end))
        ];
        $data['servicecount'] = db('contractcar')->where($where)->where('contractcar_status', 'in', 1, 2)->count();
        $data['servicestaycount'] = db('contractcar')->where($where)->where('contractcar_status', 1)->count();
        $this->assign('data', $data);
        $this->assign('message', $message);
        return $this->fetch('news');


    }
}